<?php

/**
 * BillingCreditCard form base class.
 *
 * @method BillingCreditCard getObject() Returns the current form's model object
 *
 * @package    docplus.co.za
 * @subpackage form
 * @author     Fox Matuku
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseBillingCreditCardForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'             => new sfWidgetFormInputHidden(),
      'transaction_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Transaction'), 'add_empty' => true)),
      'holder'         => new sfWidgetFormInputText(),
      'type'           => new sfWidgetFormChoice(array('choices' => array('Please select--' => 'Please select--', 'VISA' => 'VISA', 'AMEX' => 'AMEX'))),
      'cvv'            => new sfWidgetFormInputText(),
      'number'         => new sfWidgetFormInputText(),
      'expiry_date'    => new sfWidgetFormDateTime(),
      'created_at'     => new sfWidgetFormDateTime(),
      'updated_at'     => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'             => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'transaction_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Transaction'), 'required' => false)),
      'holder'         => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'type'           => new sfValidatorChoice(array('choices' => array(0 => 'Please select--', 1 => 'VISA', 2 => 'AMEX'))),
      'cvv'            => new sfValidatorString(array('max_length' => 255)),
      'number'         => new sfValidatorString(array('max_length' => 255)),
      'expiry_date'    => new sfValidatorDateTime(),
      'created_at'     => new sfValidatorDateTime(),
      'updated_at'     => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('billing_credit_card[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'BillingCreditCard';
  }

}
